//
//  Address.swift
//
//  Created by zwb on 2018/6/1
//  Copyright (c) aowang. All rights reserved.
//

import Foundation
import ObjectMapper

public final class ZyaClientAddress: Mappable {

  // MARK: Declaration for string constants to be used to decode and also serialize.
  private struct SerializationKeys {
    static let idKey = "id_key"
    static let kDel = "k_del"
    static let clientName = "client_name"
    static let clientId = "client_id"
    static let currMark = "curr_mark"
    static let clientAdd = "client_add"
    static let clientPost = "client_post"
    static let clientMoblie = "client_moblie"
    static let kLinkName = "k_link_name"
    static let kLinkPhone = "k_link_phone"
    static let kProvince = "k_province"
    static let kCity = "k_city"
    static let kArea = "k_area"
    static let kAddrType = "k_addr_type"
  }

  // MARK: Properties
  public var idKey: String?
  public var kDel: Int?
  public var clientName: String?
  public var clientId: String?
  public var currMark: Int?
  public var clientAdd: String?
  public var clientPost: String?
  public var clientMoblie: String?
    public var kLinkName: String?
    public var kLinkPhone: String?
    
    public var kProvince: String?
    public var kCity: String?
    public var kArea: String?
    public var kAddrType: String?

    
  // MARK: ObjectMapper Initializers
  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public required init?(map: Map){

  }

  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public func mapping(map: Map) {
    idKey <- map[SerializationKeys.idKey]
    kDel <- map[SerializationKeys.kDel]
    clientName <- map[SerializationKeys.clientName]
    clientId <- map[SerializationKeys.clientId]
    currMark <- map[SerializationKeys.currMark]
    clientAdd <- map[SerializationKeys.clientAdd]
    clientPost <- map[SerializationKeys.clientPost]
    clientMoblie <- map[SerializationKeys.clientMoblie]
    kLinkName <- map[SerializationKeys.kLinkName]
    kLinkPhone <- map[SerializationKeys.kLinkPhone]
    
    kProvince <- map[SerializationKeys.kProvince]
    kCity <- map[SerializationKeys.kCity]
    kArea <- map[SerializationKeys.kArea]
    kAddrType <- (map[SerializationKeys.kAddrType],StringTransform())

    
  }

  /// Generates description of the object in the form of a NSDictionary.
  ///
  /// - returns: A Key value pair containing all valid values in the object.
  public func dictionaryRepresentation() -> [String: Any] {
    var dictionary: [String: Any] = [:]
    if let value = idKey { dictionary[SerializationKeys.idKey] = value }
    if let value = kDel { dictionary[SerializationKeys.kDel] = value }
    if let value = clientName { dictionary[SerializationKeys.clientName] = value }
    if let value = clientId { dictionary[SerializationKeys.clientId] = value }
    if let value = currMark { dictionary[SerializationKeys.currMark] = value }  else {
        dictionary[SerializationKeys.currMark] = "0"
    }
    if let value = clientAdd { dictionary[SerializationKeys.clientAdd] = value }
    if let value = clientPost { dictionary[SerializationKeys.clientPost] = value }
    if let value = clientMoblie { dictionary[SerializationKeys.clientMoblie] = value }
    
    if let value = kLinkName { dictionary[SerializationKeys.kLinkName] = value }
    if let value = kLinkPhone { dictionary[SerializationKeys.kLinkPhone] = value }
    if let value = kProvince { dictionary[SerializationKeys.kProvince] = value }
    if let value = kCity { dictionary[SerializationKeys.kCity] = value }
    if let value = kArea { dictionary[SerializationKeys.kArea] = value }
    if let value = kAddrType { dictionary[SerializationKeys.kAddrType] = value }

    
    return dictionary
  }

}
